package org.vincen.springapp.service.impl.diogenes;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.vincen.springapp.dao.diogenes.DataDictionaryDao;
import org.vincen.springapp.domain.diogenes.DataDictionary;
import org.vincen.springapp.service.diogenes.DataDictionaryService;

@Service("dataDictionaryService")
public class DataDictionaryServiceImpl implements DataDictionaryService{

	@Autowired
	private DataDictionaryDao dao;
	
	@Override
	public boolean addDataDictionary(DataDictionary dd) {
		dao.save(dd);
		return false;
	}

	@Override
	public List<DataDictionary> findDataDictionaries() {
		Iterable<DataDictionary> iterable = dao.findAll();
		Iterator<DataDictionary> iterator = iterable.iterator();
		List<DataDictionary> list = new ArrayList<DataDictionary>();
		while (iterator.hasNext()) {
			list.add(iterator.next());
		}
		return list;
	}

	@Override
	public DataDictionary findDataDictionary(String key) {
		return dao.findByKey(key);
	}
	

}
